package com.sky.controller.user;

import com.sky.dto.UserLoginDTO;
import com.sky.result.Result;
import com.sky.service.UserService;
import com.sky.vo.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "微信登录接口")
@Slf4j
@RequestMapping("/user/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    @ApiOperation("微信登录")
    public Result<UserLoginVO> WeChatlogin(@RequestBody UserLoginDTO userLoginDTO){
        log.info("[微信登录] userLoginDTO：{}", userLoginDTO);
        UserLoginVO userLoginVO =  userService.loginByOpenId(userLoginDTO);
        return Result.success(userLoginVO);
    }
}
